<template>
  <div class="contain">
    <div class="contain-header">
      <el-breadcrumb separator="/">
        <el-breadcrumb-item>数据统计</el-breadcrumb-item>
        <el-breadcrumb-item>异常数据统计</el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <div class="contain-body">
      <div class="body-header">
        <el-form :inline="true" size="mini">
          <el-form-item label="异常时间">
            <el-date-picker
                v-model="page.time"
                type="daterange"
                clearable
                value-format="yyyy-MM-dd"
                range-separator="至"
                start-placeholder="开始日期"
                end-placeholder="结束日期">
            </el-date-picker>
          </el-form-item>
          <el-form-item label="医生">
            <el-select placeholder="请选择医生" clearable v-model="page.doctorId">
              <el-option :label="item.realName" :value="item.id" v-for="item in doctorList"
                         :key="item.id"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="排序">
            <el-select placeholder="请选择排序" v-model="page.sort" clearable>
              <el-option label="时间正序" value="1"></el-option>
              <el-option label="时间倒序" value="2"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" icon="el-icon-search" @click="findPage">查 询</el-button>
            <el-button type="primary" icon="el-icon-refresh" @click="reset">刷 新</el-button>
          </el-form-item>
        </el-form>
      </div>
      <div class="body-table">
        <el-table
            :data="tableData"
            style="width: 100%">
          <el-table-column
              prop="client.realName"
              label="患者姓名"
              align="center"
          >
          </el-table-column>
          <el-table-column
              prop="client.age"
              label="年龄"
              align="center"
          >
          </el-table-column>
          <el-table-column
              label="测量时间"
              align="center"
          >
            <template slot-scope="scope">
              {{ scope.row.feverDate + ' ' + scope.row.feverTime }}
            </template>
          </el-table-column>
          <el-table-column
              prop="temperatureNum"
              label="高温度数"
              align="center"
          >
          </el-table-column>
          <el-table-column
              prop="doctorUser.realName"
              label="问诊医师"
              align="center"
          >
          </el-table-column>


        </el-table>
      </div>
      <div class="body-page">
        <el-pagination
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="page.pageIndex"
            :page-sizes="[10, 15, 20, 25]"
            :page-size="page.pageSize"
            layout="total, sizes, prev, pager, next, jumper"
            :total="total">
        </el-pagination>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      tableData: [],
      page: {
        pageIndex: 1,
        pageSize: 10,
        time: [],
        doctorId: null,
        sort: null
      },
      total: 0,
      doctorList: []
    }
  },
  created() {
    this.findPage()
    this.findAllDoctor()
  },
  methods: {
    findPage() {
      this.axios.post('/admin-temperature-monitor/findPage', this.page).then(res => {
        if (res.data.code === 200) {
          this.tableData = res.data.data.data
          this.total = res.data.data.total
        }
      })
    },
    reset() {
      this.page.pageSize = 10
      this.page.pageIndex = 1
      this.page.doctorId = null
      this.page.time = []
      this.page.sort = null
      this.findPage()
    },
    handleSizeChange(val) {
      this.page.pageSize = val
      this.findPage()
    },
    handleCurrentChange(val) {
      this.page.pageIndex = 1
      this.findPage()
    },
    //查询全部医生
    findAllDoctor() {
      this.axios.post('/admin-doctor/findAll').then(res => {
        if (res.data.code === 200) {
          this.doctorList = res.data.data
        }
      })
    },
  },
}
</script>

<style scoped lang="less">
.contain {
  width: 100%;
  height: 100%;

  .contain-header {
    width: 100%;
    height: 50px;
    display: flex;
    align-items: center;
  }

  .contain-body {
    width: 100%;
    height: calc(100% - 50px);
    background-color: #fff;
    padding: 1%;
    box-sizing: border-box;

    .body-header {
      width: 100%;
      height: 50px;
    }

    .body-table {
      width: 100%;
      height: calc(100% - 120px);
    }

    .body-page {
      width: 100%;
      height: 70px;
      display: flex;
      align-items: center;
    }
  }
}
</style>
